<template>
  <div class="app-container">
    <div ref="chartContainer" style="width: 800px; height: 600px;"></div>
  </div>
</template>

<script>
  import * as echarts from 'echarts';
  import { userAll} from '@/api/newTc'
  export default {
    name: 'userNumber',
    data() {
      return {
         chart: null,
      }
    },
    mounted(){
      this.userAll()
    },
    methods: {
      userAll(){
        userAll().then(res=>{
          console.log(res)
          let data = [res.data.num1,res.data.num2,res.data.num3,res.data.num4]
          console.log(data)
          this.initChart(data)
        })
      },
      initChart(data) {
        this.chart = echarts.init(this.$refs.chartContainer);
        this.chart.setOption({
          title: {
              text: '用户总数'
            },
            tooltip: {},
            xAxis: {
              data: ['总监数量', '经理数量', '主管数量', '门店数量']
            },
            yAxis: {},
            series: [
              {
                name: '人数',
                type: 'bar',
                data: data
              }
            ]
        });
      }
    }
  }
</script>

<style scoped>
  .app-container {
    margin-top: 40px;
    margin-left: 120px;
    margin-right: 120px;
    min-height: 500px;
  }
  .top {
    display: flex;
    align-items: center;
    margin-bottom: 50px;
  }

  .topSearch {
    width: 300px;
    display: flex;
    align-items: center;
  }

</style>
